<template>
	<view class="page">
	<u-sticky>
		<view class="u-padding-20 u-flex " style="background: #FFFFFF;">
			<view style="width: 700rpx;">
			<u-search placeholder="请输入您想搜索的商品" :v-model="initial.parm.keyword" :animation="true" bg-color="#fff"
				border-color="#333" @custom="Skeyword" @search="Skeyword">
			</u-search>
			</view>
		</view>
		<dropdown ref="dropdown" @updata="getupdata"></dropdown>
	</u-sticky>
	

	
	
	<shopList :list="list"  v-if="list.length" @go="go"   >
		<template v-slot:btn="{item}">
			<u-button @click="go_detail(item)" shape="circle" size="mini" :custom-style="{background:'#FF5D39',color:'#fff'}" >立即抢购</u-button> 
		</template>
	</shopList>
	
	<u-loadmore :status="initial.status" />
	
	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	import shopList from "@/components/shopList.vue";
	import {Class} from '@/untils/common.js';
	import dropdown from "../../components/dropdown.vue";
	
	
	export default {
		mixins: [loader],
		components:{
			shopList,
			dropdown,
		},
		data() {

			return {
				tabbar: [],
				nav: [],
				current: 0,
				list: [],
				initial: {
					geturl: "/index/goods",
					parm: {
						 keyword:"",
						 goods_type:4,
						 cate:'',
						 top:''
					},
					isPage: true
				},




			}
		},
		async onLoad() {
		
			this.getGoods()
			
			this.getclass()
			
			
		},
		methods: {
			Skeyword(e){
				this.initial.parm.keyword=e;
				this.initial.page=1;
				this.getGoods()
			},
			go_detail(e){
				uni.navigateTo({
					url:"/pages/sure_book/index?id="+e.id
				})
				// uni.navigateTo({
				// 	url:'./detail?id='+e.id
				// })
			},
			go(item){
			
				uni.navigateTo({
					url:'./detail?id='+item.id
				})
			},
			
			getclass(){
		     	Class("/index/goodsCate").then(res=>{
					this.$refs.dropdown.nav = res;
				})
			},
			
			getupdata(e){
				var obj1 = this.$refs.dropdown.nav;
				var Obj = {};
				obj1.map(item => {
					if(item.obj){
						Obj[item.enName]=item.obj.id
					}
				})
			    this.initial.parm.cate=Obj
				this.initial.page=1;
				this.getGoods()
			}
		
			
			
			
		}
	}
</script>


<style>
	
</style>
